My preceding module in Integromat gives me an expiration date in UNIX time, which is 1640930400.
When I use the FormatDate function to convert this, I'm getting 12/31/1969 when I was expecting to get 12/31/2021. I can't seem to figure out what I'm doing wrong here. Any help would be much appreciated.
Use this instead to first parse the date and then apply the desired formatting to get the results that you want,
{{formatDate(parseDate(1.date; "X"); "MM/DD/YYYY")}}
Related
I have a DateTime variable (default formatting), and I would like to format it to a format to I receive from a string parameter.
I normally do something similar to: {myDate:yyyy-MM-dd}, and it works properly.
Now I have a lot of possible date formats and need to format according to the chosen one.
I have tried the following but returned garbage (ae0aor0aa):
string testFormat = "yyyy. MM. dd.";
{myDate:testFormat }
I have also tried to convert the date to string and back to date with ParseExact, but gave me an invalid date exception. NB: the date in myDate is valid, as I have checked it with the debugger.
Can you kindly advise?
Thanks to apc, it was easily solved by myDate.ToString(testFormat)
I need to convert a string formatted as MM/DD/YYYY HH:MI plus AM/PM, but can't find a complete reference to the format string to find how to specify the AM/PM part.
I would certainly appreciate information on how to do this, but would appreciate a link to a good source of documentation for this even more.
:EDIT
SELECT top 1
v.CalendarDateTime
,TO_TIMESTAMP(v.CalendarDateTime,'MM/DD/YYYY HH:MIAM') as CalendarDateTimeTS
--,CAST(TO_TIMESTAMP(v.CalendarDateTime,'MM/DD/YYYY HH:MIAM') AS TIMESTAMP(0) FORMAT 'MM/DD/YYYYBHH:MIBT') AS CalendarDateTimeTS2
12/03/2015 03:00AM 12/3/2015 03:00:00.000000
The commented out line produces a "DateTime field overflow" error.
You probably want TO_TIMESTAMP instead of TO_DATE.
The only bad thing about the Oracle function is the resulting datatype of TIMESTAMP(6) which can't be changed:
TO_TIMESTAMP('12/03/2015 03:00AM', 'MM/DD/YYYY HH:MIAM')
Using Teradata's FORMAT you can specify the timestamp precision, but it's less flexible than Oracle's, the string must match the format exactly:
CAST('12/03/2015 03:00AM' AS TIMESTAMP(0) FORMAT 'MM/DD/YYYYbHH:MIT')
On the Teradata site you'll find the (slow) online docu, e.g. TO_DATE formats or Teradata FORMATs. Of course you should download the full documentation CD for your release.
Please tell us at least which programming language are you using.
Normally it would be something like "MM/DD/YYYY HH:MI a" but we need to know first you language.
I am currently writing a block of code on R which collects data via a SPARQL query. My problem is when I am trying to filter the query by date, R gives an error of "unexpected numeric constant".
There is no any mistake in the SPARQL code because when I run the exact code on the endpoint I receive data normally.
You will find the block of code where I have the problem. It does not matter the lines before and after, just the second line of the date filter.
...
OPTIONAL {?seller gr:legalName ?sellerLegalName} .
FILTER REGEX (STR(?date) >= "2015-01-01") .
FILTER NOT EXISTS {?spendingItem elod:hasCorrectedDecision ?correctedDecision} .
...
Please, I would kindly ask for your help! :)
For any further information that you want in order to solve the problem, feel free to contact with me.
Thank you all!!!
SOLVED!
I found that the date should be passed as timestamp!
Also, I found a useful site where you can convert any date in timestamp and vice versa.
I would like to thank you all for your responses and your useful help!
You should filter it as a date/time value rather than as a string - perhaps that will help:
FILTER (?date > "2015-01-01"^^xsd:date)
See this answer: SPARQL date range
I have a redis stored timestamp when I get it, it looks like this:
1454803149444
Then when I try to do:
i.text-muted.createdAtPost= moment(post.timestamp).format("MM/DD/YY # h:mm:ss") // Jade Template
I get
Invalid Date
But if I take the same integer, and go moment(1454803149444).format(h:mm:ss") I get 05/21/54 # 12:00:00
Any information would be great thanks.
I had the same problem. What I did was
let time = post.timestamp / 1000;
let formatted = moment.unix(time).format("MM/DD/YY # h:mm:ss");
I have no idea why this works. I tried forcing the value into an integer and still got invalid date. I hard coded the value that was console logged and it worked, like in your case. For some reason dividing it by 1000 and calling it a unix timestamp works fine. Seems like a bug to me.
What value does timestamp pass?
Did you check that?
If it has a specific format you need to set it as:
moment(post.timestamp, 'YYYY/DD/MM').format("MM/DD/YY # h:mm:ss")
Will it be possible to suppress messages such as "Using date format..." when using a function like?
> ymd(vec)
Using date format %Y%m%d
Whilst these are good to see when you are casting a vector, it can be annoying in some circumstances.
Looking at the ymd code, it callse parse_date, which gives those annoying messages via the command message.
Looking at ?message, there is a corresponding suppressMessages:
suppressMessages(ymd(x))
(Note - other similar functions are suppressWarnings, suppressPackageStartupMessages, and capture.output, all of which I have had to use in the past to stop unexpected bits of text turning up (I was outputting some bits to an HTML file and these didn't want these to be in it)).
Manny, suppressMessages() is the only way to go at the moment. But I like your idea of an argument. I've put it on the todo list for lubridate. You could also use strptime() once you have the format for a vector of date-times.