473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to convert datetime value to double in access and SQL?

Hello
I have a problem and I don't know how to sort it out. Why when I convert a date value to double in access vba I receive a value and when I convert the same data value to decimal in sql I receive a diferent value.

Example:
Access vba
Expand|Select|Wrap|Line Numbers
  1. dim data as date
  2. data=date (today is 04/01/2011)
  3. msgbox(cdbl(data)) 
  4.  
The resuls of this code is 40547

SQL
Expand|Select|Wrap|Line Numbers
  1. set dateformat 'dmy'
  2. seclare @data datetime, @variabila decimal
  3. set @data='04/01/2011'
  4. set @variabila=convert(decimal,@data)
  5. print @variabila
  6.  
the result returned is 40545

I realy don't understand why is this happening, in my opinion it should return the same result in both cases.
Jan 4 '11 #1
2 4982
Selun
6
Edit.
Sorry for hijacking, i had no clue.
Jan 4 '11 #2
Rabbit
12,516 Expert Mod 8TB
Ravenort, Access stores dates using 12/30/1899 as the origin point. Meaning that 12/30/1899 is 0. Why they chose to do this, I do not know. Whichever DBMS you're using stores dates using 1/1/1900 as the origin point.

Selun, start your own thread, don't hijack this one.
Jan 4 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Loi Tan Vo | last post by:
Hi, I have a text file that contains a date column. The text file will be imported to database in SQL 2000 server. After to be imported, I want to convert the date column to date type. For...
4
by: cindy liu | last post by:
Hi, In .Net, how to convert a string to a double? Thanks in advance! Cindy
2
by: Jelena via SQLMonster.com | last post by:
Does anybody can help me to convert datetime value let's '1936-04-13 07:00:00.000' to DATE as '04/13/1936'. I need this value in the Excell as a DATE format. Thanks in advance
1
by: ABC | last post by:
How to convert a date string to datetime value with custom date format? e.g. Date String Date Format Result (DateTime value) "05/07/2004" "MM/dd/yyyy" May 7, 2004 "01062005" ...
2
by: ziggislaw | last post by:
hello how can I convert DateTime from "25.12.2005" to "2005-12-25 00:00:00.000" ? Now I have DateTime as string (I get it from <asp:label>). Thanks
2
by: mikejacobz | last post by:
Hi, I am using the Enterprise Application Blocks (Data Access Application Block 2005) and all I want to do is pass in a date as a parameter to a Stored procedure. e.g private void...
3
by: huohaodian | last post by:
Hi, How can I convert a value created from DateTime.Now() to the datetime format that SQL Server recognises? Thanks in advance.
2
by: raam | last post by:
create proc getproviders as begin select ProviderType,ProviderTypeId,ProviderName,City,State,Country, ...
0
by: androm | last post by:
when i run my code i get this error message "Failed to convert parameter value from a SqlParameter to a DateTime." & i couldn't find what is wrong..... here's my code protected void...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.