Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 99
  • Last Modified:

finding day in month c#

Hi: I have an incremental backup system that runs every day, backing up any files modified in last day. However what I would like to do is, at the beginning of each month, copy absolutely everything from source to backup. Then increment from that. Thus at the start of each month I would have a 'full' backup. Ideally the full backup would run on a saturday so I envisage a line saying  something like 'if today is saturday and not yet  the 7th day of the month, backup everything, else backup incrementally'. I can do all the backup stuff, but stuck on 'day of month'. Can anybody help? Thanks!
0
ClaytonGlass
Asked:
ClaytonGlass
  • 2
  • 2
1 Solution
 
Rgonzo1971Commented:
Hi,

pls try

DateSerial(Today.Year, Today.Month, 7)

Today.DayOfWeek

Regards
0
 
käµfm³d 👽Commented:
Are you referring to something like:

DateTime now = DateTime.Now;

if (now.DayOfWeek == DayOfWeek.Saturday && now.Day < 7)
{
    // full backup
}
else
{
    // incremental backup
}

Open in new window

0
 
ClaytonGlassAuthor Commented:
Ahhh...so Now.Day is day of month, not day of week?
0
 
ClaytonGlassAuthor Commented:
Thank you very much! Looks like the way to go!
0
 
käµfm³d 👽Commented:
so Now.Day is day of month, not day of week?

Yes. You can see that in the Intellisense popup also:

Screenshot
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now