Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-10-2018, 01:28 PM   #1
Spackle
Newly Registered User
 
Join Date: Jul 2018
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Spackle is on a distinguished road
Date Function returning wrong date

I must be missing something basic here.

I'm looking for today's date, but when I run this,

Code:
 
Msgbox Date
I get yesterday's date.

I've checked that the system date on the computer is definitely correct, so what else could be affecting it? I've already searched for answers, but no luck

Spackle is offline   Reply With Quote
Old 08-10-2018, 01:45 PM   #2
lpapad
Newly Registered User
 
Join Date: Jul 2018
Location: Greece
Posts: 42
Thanks: 11
Thanked 4 Times in 4 Posts
lpapad is on a distinguished road
Re: Date Function returning wrong date

What about timezone?
lpapad is offline   Reply With Quote
Old 08-10-2018, 03:01 PM   #3
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 31,679
Thanks: 9
Thanked 3,796 Times in 3,739 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Date Function returning wrong date

Do you have a field on the form named Date? You shouldn't name a field that, but you can disambiguate:

MsgBox VBA.Date

__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by pbaldy; 08-10-2018 at 03:43 PM. Reason: fix spelling goof
pbaldy is offline   Reply With Quote
Old 08-10-2018, 03:32 PM   #4
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 11,989
Thanks: 56
Thanked 1,093 Times in 999 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Date Function returning wrong date

I am unable to reproduce your problem using both Debug.Print Date and Msgbox Date when in the Immediate Window. (Yes, MsgBox works in the immediate window). Is it always wrong for you? And can you try Now(), perhaps with a FormatDateTime function and the General Date option to see if the time of day is also wrong?

Is there a chance that an Excel App object is in play here? Because Access and Excel use reference dates that differ by one day. So things COULD get confused depending on context.

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CDate function returning Error when no date David Ball Queries 2 12-24-2015 06:32 PM
display date/time based on weekday(date()) function lynnsf Queries 7 07-07-2015 09:28 AM
Date command returns wrong date despite system date being correct michal79 Visual Basic 8 03-05-2013 06:05 AM
Returning Records with a Certain Date from a DCount Function Tezcatlipoca General 4 12-21-2008 03:10 AM
Date() returning wrong date (30/12/99) Nelmo Modules & VBA 4 09-30-2003 07:34 AM




All times are GMT -8. The time now is 04:57 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World