What is the way to use universal SQL date format in MS Access? - sql-server

In SQL the universal date format is YYYYMMDD
For example. To search records greater than 15 Jan 2021 I write:
Where Datecol>='20210115'
This works irrespective of US or UK machine.
Is there an equivalent of this in the MS Access database?

Access uses octothorpes and separators:
Where Datecol >= #2021/01/15#

Related

Unexpected Dateformat in sql server when dates are in dd/mm/yy format

I have data in excel sheet that I am importing into sql server. data in excel sheet contains some dates in dd/mm/yy format. sql server allows me to import the date as it is and appends the century to make it complete four digit year. yyyy-mm-dd but in some cases it has guessed it correct and some cases it has guessed it wrong.
for example I have date column with values like
01/01/99
01/09/84
01/07/62
03/03/48
sql server prefixed the correct century for first three values but for the last value it add in sql server as 2048-03-03
why is this and how can i fix it. thank you for your help in advance :)
This is because of the Two Digit Year CutOff Property on your server level setting.
If you goto your SSMS , right click on your server name --> Properties --> Advance tab .
You will see a value there I think by default it is set to 2049, which means if you pass a value like your format dd/mm/yy SQL Server will complete the year bit depending on the value of YY in your passed values where YY value is greater than 49 Sql Server assumes it is 19th Century
for example 01/01/99 will become 01/01/1999
on the other hand if the value of YY is less than 49 Sql Server assumes it is 20th century.
For exmaple in your case 03/03/48 became 03/03/2048 in your sql server.
FIX
You can decrease the range of cut off year like 2020 which means if there is a value less than 01/01/20 on then sql server will assume it is 01/01/2020 any thing greater then 20 in your YY will be assumed as 19YY

Excel Power Query - convert date time from UTC to Local

I'm connecting to an MS SQL database via Power Query (Version: 2.10.3598.81) in Excel 2010.
My dates are stored in UTC in the database, however I would like to show them as local in the spreadsheet.
DateTimeZone.From() - converts to a DateTimeZone type but assumes the input date is in the Local timezone. This is the exact opposite of what I want.
DateTimeZone.ToLocal() - gives an error, I think because there's no timezone information in the source date.
Local in my case is Australian EST, however it would be great if Excel just picked up the local timezone. (It appears to do this already)
I think I've discovered the answer.
The function DateTime.AddZone() which I thought was used to convert between timezones is actually used to add timezone information to an existing date. If your date is UTC you would use DateTime.AddZone([date_created],0) and if your date was already in AEST then you would use DateTime.AddZone([date_created],10).
So I can now use:
DateTimeZone.ToLocal(DateTime.AddZone([date_created_UTC],0))
and Power Query will correctly convert my date created from UTC to AEST (or whatever is local).

Convert like America/New_York in MySQL server 2008 R2 server

13:30:00 Friday April 19, 2013 in America/New_York converts to
09:30:00 Friday April 19, 2013 in America/Anchorage
Convert like this in SQL Server 2008 R2.
using select query.
Please help me on this.
Thanks,
we will convert in java wright from "America/New_York" to America/Anchorage like way i need a select query to convert EST time to other time zones..please not the time zone cannot be given like MET,GMT and all...
PLEASE NOTE:- All time zones will only be like plain text America/Anchorage
You are looking for this function:
CONVERT_TZ(dt,from_tz,to_tz)
CONVERT_TZ() converts a datetime value dt from the time zone given by from_tz to the time zone given by to_tz and returns the resulting value. Time zones are specified as described in Section 10.6, “MySQL Server Time Zone Support”. This function returns NULL if the arguments are invalid.
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_convert-tz

Transposed day and month values in MS Access 2007 when using Update Query in SQL View

I have a challenge saving the date to an MS Access 2007 database especially for dates with the day less than the 12th of a month (i.e. the day between 01 to 11) If for example a February date - 07/02/2013 (dd/MM/yyyy) will be saved as 02/07/2013 in the database. While a similar February date 14/02/2013 will also be saved 14/02/2013. Retrieving the two dates: The first date will brought out as 2nd July and the second date will be 14th February.
Notice that the day and month values is transposed for dates less than the 11th. This happens when I use an update query (either from VB 2005 or directly within MS Access using SQL pane). I have set both the system short date settings (in Windows 7 OS) and the Date Format at field level (in the MS Access Table) to dd/MM/yyyy.
try - DateValue("dd-mm-yyyy")
or - Format(Date,"dd-mm-yyyy") as an expression builder.

Converting number to date in oracle

I have a numeric field in my Oracle database that represents the number of days since Dec 28, 1800. However I am trying to select it (for another application) as the current date it represents. I'm not too familiar with Oracle commands (I'm used to SQL), so I was wondering if anyone could provide some assistance. Thanks.
ex: 77650 = Saturday, August 3, 2013
Firstly, get this out of the way, your life would be easier if you stored dates in a date data-type.
However, to answer your question to add days to a date in Oracle you can use the + operator.
Firstly though you have to have a date so I'll convert the 28th December 1800 into a date using to inbuilt to_date function then add the number. In your case you would want:
select to_date('1800/12/28','yyyy/mm/dd') + 77650 from dual
I've set up a little SQL Fiddle to demonstrate for you.

Resources