If I have a Date parameter such as:
03. Mar at 5:00pm PST
and I only need to break it down by date so that my end result is:
03. Mar
how can I achieve that?
Is there a substring equivalent syntax in Google BigQery? Or maybe a date/time function to show only date and ignore the time?
Thanks
Is this a string manipulation question? Then the answer would be getting the LEFT() 2 characters of that string.
If this is a date manipulation question:
SELECT TIMESTAMP('2014-03-03 05:00:00')
2014-03-03 05:00:00 UTC
SELECT DATE(TIMESTAMP('2014-03-03 05:00:00'))
2014-03-03
SELECT DAY(TIMESTAMP('2014-03-03 05:00:00'))
3
Related
I have Column that is in String format such as 2018-03 and I want to convert this to Date format in tableau. Once I have convert these 4 years data I want to compare 2019 data with 2018 and 2021 data with 2020s
To convert to a date use the DATE function:
DATE(LEFT([DateField],5)+RIGHT([DateField],2)+"01")
Check here to see 2 different ways to do YoY - do whichever works better for your use case.
Assuming that 03 in your date 2018-03 corresponds to month, you can convert the string column to date column with the following calculation, where my_date is your string column
DATE(DATEPARSE("yyyy-MM", [my_date]))
See the results
Note, if however, 03 is quarter, use this calculation instead
DATE(DATEPARSE("yyyy-qq", [my_date]))
I was able to successfully parse some text into a date but then found that all of the Sept dates were returning NULL. Here is an example of the string I started with:
Apr 02, 2011 at 8:15 am
I used the following to create a date from it.
date(str([Date])) and the Sept dates return NULL
When I remove the str() the Sept dates return #Error
Any ideas on how to get the September dates to return properly? Here is an example of the exact record for one. Sept 03, 2010 at 6:27 am The only difference that I see is that September records use a four letter month abbreviation.
In an ideal world your ETL process cleans data.
But, if your Tableau source data is not enough cleaned, you can massage it with some Tableau functions. For your issue:
REPLACE(string, substring, replacement)
Searches string for substring and replaces it with replacement. If substring is not found, the string is not changed.
Some ideas:
date(replace(str([Date])), "Sept", "Sep" )
What is the best way to store indian date and time in mongodb?
I'm going to upload bill details in mongodb. So i've to capture the Bill time which is printed in Bill. This will be in the format like '2014-12-22 14:10:25'. ISODate is good solution? How to covert above date value into ISODate format? Is there any default fuction avilable in mongodb?
How to query the documents based on time elements.For example hourly wise document search.
Please advice
that is possible through JavaScript's Date objec, that supports the ISO date format, so as long as you have access to the date string, you can do something like this:
> doo = new Date("2012-07-14T01:00:00+01:00")
Sat, 14 Jul 2012 00:00:00 GMT
> doo.toTimeString()
'17:00:00 GMT-0700 (MST)'
If you want the time string without the seconds and the time zone then you can call the getHours() and getMinutes() methods on the Date object and format the time yourself.
if any problem please comment me..)
I am working with a legacy system whereby it seems they store dates as integers, such as 733473. Anyone seen this format before and can think of the logic to turn this into a date? It appears to be a day number, but not sure how many days from what date!
Edit: the value I get for 01/01/2013 is 734869. It is the amount of days since 0 i believe, but does this have a name? I need to write/find a native function in MSSQL server to convert these.
You are most likely correct, it's the number of days since Jan 1, year 0000 (or possibly 1).
$ date -u -d "0000-01-01 + 733473 days"
Fri Mar 7 00:00:00 UTC 2008
However, without knowing the date it actually corresponds to, we can't know for sure which leap year system it follows.
OK not sure the name of this date type (if there is one), but the below works:
declare #dt datetime2 = '00010101'
declare #int int = 734869
select dateadd(day,#int-1,#dt)
2013-01-01 00:00:00.0000000
This question already has an answer here:
Changing a nvarchar column into a Date format [closed]
(1 answer)
Closed 9 years ago.
How do I convert Nov 28 2012 3:56PM into yyyy-mm-dd HH:MM:SS. I have a column with incorrectly formatted dates and I need to change the format.
CONVERT (datetime, 'Nov 28 2012 3:56PM', 120)
That should work, more info: http://msdn.microsoft.com/en-us/library/ms187928.aspx
Assuming that you want convert a DATE to VARCHAR, this query maybe will be useful:
SELECT CONVERT(VARCHAR(50),CAST('Nov 27 2012 3:56PM' AS DATETIME),120)
In your case, for example, if you field date is FIELD then your query will be:
SELECT CONVERT(VARCHAR(50),FIELD,120)
You can try this here.
120 is a DateStyle for yyyy-mm-dd hh:mi:ss(24h)
Note: the size of VARCHAR it depends on the format you have chosen.