Define todays date - How to...

TheToeOfPooh

Active Member
Joined
May 21, 2004
Messages
254
I have searched and can not find an answer as to how today's date is defined using VBA.

e.g.
strToYearDate As String * 4 'I can set as 2004

strToMonthDate As String * 2 'I can set as 09 for Sept

strToDayDate As String * 2 'How do I set this to automatically change?

e.g. strToDayDate will be 13 (As it is the 13th of Sept), but tomorrow I need it to automatically increase to 14,etc.

I will change the Year and Month dates manually unless there is a simple routine for this too?

I am using this code "behind" a command button on a form named
Current job Reports.
When the user selects this button they start a process which produces a job duplication and variation report. All that works but I can't get this first part sorted.

(Currently I am typing in all the dates using InputBoxes).

Anyone able to advise me what I need to do please?

Bernard
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
The DATE function grabs today's date from the system clock. So...

ToMonthDate = Format(Date,"mm")
ToYearDate = Format(Date,"yyyy")
ToDayDate = Format(Date,"dd")

You can also use NOW instead of DATE

Denis
 
Upvote 0
Denis

Many thanks that worked fine.

Delay in my reply is due to user group then asking for a set of buttons (one for each day of the year) to make things more logical for them.

But I would'nt of been able to crack first problem without your help.

:cool:

Bernard
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,132
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top