Solved

finding day in month c#

Posted on 2014-10-07
5
85 Views
Last Modified: 2014-10-07
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
Comment
Question by:ClaytonGlass
  • 2
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 40366026
Hi,

pls try

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

Today.DayOfWeek

Regards
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40366052
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
 

Author Comment

by:ClaytonGlass
ID: 40366063
Ahhh...so Now.Day is day of month, not day of week?
0
 

Author Closing Comment

by:ClaytonGlass
ID: 40366084
Thank you very much! Looks like the way to go!
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40366106
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now