+ Reply to Thread
Results 1 to 6 of 6

Is today the 1st of month/year

Hybrid View

  1. #1
    Registered User
    Join Date
    10-13-2011
    Location
    Jozi, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    93

    Is today the 1st of month/year

    Hello,

    I need code to check if today is the 1st of the month and another snippet to check for 1st of Jan.

    something like:

    if today = 1st of current month then
    do something
    else
    do something
    end if
    and for 1st Jan:

    if today = 1st Jan then
    do something
    else
    do something
    end if
    ***------ Coding for Fun ------***

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,657

    Re: Is today the 1st of month/year

    Use
    if DAY(DATE) = 1 then
    'do something
    else
    'do something
    end if
    if DAY(DATE)*MONTH(DATE) = 1 then
    'do something
    else
    'do something
    end if
    Best Regards,

    Kaper

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Is today the 1st of month/year

    for 1) try:
    If Format(Date, "d") = 1 then
    ... do something
    Else
    .... do something
    End If
    for 2) try:
    If Format(Date, "d") = 1 and Format(Date, "m") = 1 then
    ... do something
    Else
    .... do something
    End If
    HTH!

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Is today the 1st of month/year

    Perhaps.
    If Day(Date) = 1 Then 
        ' do a thing
    Else
        ' do another thing
    End If
    
    If Day(Date) = 1 And Month(Date) = 1 Then
        ' do that other thing
    Else
        ' do something else
    End If
    If posting code please use code tags, see here.

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,657

    Re: Is today the 1st of month/year

    3 solutions in the same minute!
    2 approaches: Norie's and mine is basically the same, because
    Day(Date) = 1 And Month(Date) = 1
    having in mind that days and months are integers can be rewritten as
    DAY(DATE)*MONTH(DATE) = 1

  6. #6
    Registered User
    Join Date
    10-13-2011
    Location
    Jozi, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    93

    Re: Is today the 1st of month/year

    WOW....fast....guys, thanks so much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Formula for today's date as year month day
    By Jahzeal in forum Office 365
    Replies: 3
    Last Post: 10-21-2013, 06:50 AM
  2. If Column A Month and Year = ColumnB Todays Month and Year then send email
    By HACCStaff in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-15-2013, 12:47 AM
  3. [SOLVED] display cell to show only Month/year to do sumif calc if today()= any day of month
    By fireguy7 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-12-2013, 06:55 PM
  4. [SOLVED] Excel 2007 : Convert Today's Date To The Previous Month & Year
    By The_Snook in forum Excel General
    Replies: 8
    Last Post: 04-26-2012, 06:37 AM
  5. Conditional Format (month and year) = Today()
    By Scott in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-04-2005, 12:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1