You are viewing a single comment's thread from:

RE: Engagement away from home

in #engagement4 years ago

Good trick to SUBSTRINGify the url to find the post author.

But when dealing with dates, you should use ANSI date format (YYYY-MM-DD) because you do not know the locale of the server. Would it be a different date format than US (MM/DD/YYYY), or change to a different format, your query will fail.

By replacing created > '03/20/2020 15:00:00' with created > '2020-03-20 15:00:00', your query will never fail, whatever the locale of the server.

Add to this that the latest format is more "universal" and is less confusing.

Sort:  

It does the job :)

Thanks for the tip on dates. I usually take the day month year out of timestamp/created and build my own date - much easier when exporting to excel I find.

select
cast(day(timestamp)as varchar(20)) + '/' + cast(month(timestamp)as varchar(20)) + '/' + cast(year(timestamp)as varchar(20))

If you plan to export a date part to Excel, better (and faster) to use CONVERT(DATE,timestamp)

That works, cheers :D

yoda.png Your SQL skills, improved they are now!