Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Current Date Error 1

Status
Not open for further replies.

jt463

IS-IT--Management
Nov 23, 2005
134
I have the following code:

Code:
Dim datSQL, timSQL As Date

datSQL = Date
timSQL = Time

Everything has worked great until today. The code is pulling the current time, but it is not pulling the date.

To see whether or not the system time can even be seen within VB, I tried the following code:

Code:
Dim datSQL As Date

datSQL = Now()

That pulls back:

hh:mm:ss mm/dd/yyyy (current data)

I looked at my system time/date in 'Control Panel', and it shows there. I am wondering if it has something to do with Daylight Savings time. I am pulling at straws.

Any help would be greatly appreciated.
 
Only thing I can see is that "datSQL" is a Variant ... not a Date data type. It should still pull the value from the "Date" function though.

What are you doing to determine that "datSQL" has no value (or an incorrect value)?

[small]On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. (Charles Babbage)[/small]
 
I am placing a break on the code directly below where I set the date. I hover over the datSQL = Date, and the value is Null.

I am also getting an 'Invalid Use of Null' error.

Lastly, I have the same code used elsewhere, and there is no error. But the record is just blank.
 
Sounds weird but try
Code:
Dim datSQL [COLOR=red]As Date[/color], timSQL As Date

datSQL = Date
timSQL = Time

[small]On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. (Charles Babbage)[/small]
 
Just in case you have an object named Date:
datSQL = VBA.Date()

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV - your suggestion was perfect. I updated my code, and it worked great!

I think that I have an object named Date...

Thanks also Golem for your input and troubleshooting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top