473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Getting the first day of the month

I have a calendar and i'm getting the first day of the month by doing so
below
calendarstartdate.SelectedDate =
Convert.ToDateTime(String.Format("{0:yyyy/MM/1}",DateTime.Now));
Are there better ways to do this?
Any ideas
Aug 30 '06 #1
2 1291
"Patrick.O.Ige" <na********@hotmail.comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
>I have a calendar and i'm getting the first day of the month by doing so
below
calendarstartdate.SelectedDate =
Convert.ToDateTime(String.Format("{0:yyyy/MM/1}",DateTime.Now));
Looks OK to me...
Are there better ways to do this?
There are other ways, certainly, but I wouldn't have thought any was
particularly better or worse...
Aug 30 '06 #2
I have a calendar and i'm getting the first day of the month by doing so
below
calendarstartdate.SelectedDate =
Convert.ToDateTime(String.Format("{0:yyyy/MM/1}",DateTime.Now));
Are there better ways to do this?
Any ideas
Without converting to/from a string:
DateTime nu = DateTime.Now;
DateTime first = new DateTime(nu.Year, nu.Month, 1);
Hans Kesting
Aug 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Morgan | last post by:
Hi Hopefully the subject says it all. Given a weekday, (1 to 7) and an occurrence with in a month, (1 to 4), I need to ascertain the date on which it first occurs in any given month and year. ...
2
by: Fawke101 | last post by:
Hi there, I have a field in my SQL database - dtePurchased - and the values look like this - 24/03/2004, 35/03/2004 (UK format) I wish to display this field in a table on my ASP page by using...
5
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
4
by: laredotornado | last post by:
Hi, Using PHP 4, if I have a date, what is a function I could use to give me a date that represents the first day of that month? For example, if my date were "3/19/2006 8:00", I would want my...
1
by: Timothy.Rybak | last post by:
I need help designing a database that keeps up with a point system we have here at work. I'll tell you what I know. First, I have a list of all the employee names for a table. Second, for...
2
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
0
by: preeti13 | last post by:
i have a two tables employeenominations and reason if someone storing a data first time it will store into the employeenominations table if name is already exist it will store into the reason table...
2
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.