VBA CDate does not match Convert (datetime,) in SQL Server 2005

In Access 2003 VBA (uses an immediate window)

? CDate(39870) 

Refund: 2/26/2009

In SQL Server 2005 (SQL Server Management Studio)

SELECT CONVERT(DATETIME, 39870)

Refund: 2009-02-28 00: 00: 00.000

Do they always differ by 2 or are there any other date settings that I don’t have?

Server Collation = SQL_Latin1_General_CP1_CI_AS

+3
source share
2 answers

Different languages ​​and systems use different numeric representations of dates.

SQL 2005 counts the number of days since 1/1/1900:

SELECT CONVERT(DATETIME, 1)
1900-01-02 00:00:00.000

Excel and Access VBA count the number of days since 12/30/1899:

? CDate(1) 
12/31/1899 

, - , , . , MS DOS 31 1990 . UNIX 1/1/1970.

( ). (01-03-2009), .

: VBA . . .

+6

.

12/30/1899

SQL Server 1/1/1900

.

.

+1

Source: https://habr.com/ru/post/1705584/


All Articles