Check dates between .txt File and DB (1 Viewer)

gstylianou

Registered User.
Local time
Today, 15:54
Joined
Dec 16, 2013
Messages
357
Good Evening,

I have two dates, date A = 01/01/2023 and date B = 12/12/2022. I would like to break into it

1. Days (ie for A =01 and B=12)
2. Months (A=01 and B=12)
3. Year (A=2023 and B=2022)

The issue is

There is an external .txt file which include the first date (A) and I have the B date into my DB. I need the following

1. If the year is the same between A & B dates (for example 2023) i must get the result [Date1]=True and vice versa [Date1]=False when are not the same year

2. If Date() is more than 365 days away to from the date into .txt file i must receive [Date2]=False or [Date2]=True if is within the range of 365 days..

I would appreciate your help or any idea
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:54
Joined
Feb 28, 2001
Messages
27,186
Look into the DatePart function, which will easily break the dates up into their parts as you named. The input HAS to be in date format. The code (using fictitious names) might resemble

ADate = CDate( "#" & ADateString & "#" ) 'if the input was a text variable, not needed otherwise
ADay = DatePart( "d", ADate )
AMth = DatePart( "m", ADate )
AYr = DatePart( "yyyy", ADate )


Note that I took the defaults for the 3rd and 4th arguments of that function because nothing you asked for needed special handling. The week-related functions might require one or both of those extra arguments, but day, month, and year do not.
 

Users who are viewing this thread

Top Bottom