Solved

finding day in month c#

Posted on 2014-10-07
5
83 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 48

Expert Comment

by:Rgonzo1971
ID: 40366026
Hi,

pls try

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

Today.DayOfWeek

Regards
0
 
LVL 74

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 74

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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…

757 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

20 Experts available now in Live!

Get 1:1 Help Now