Solved

finding day in month c#

Posted on 2014-10-07
5
89 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 51

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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