hi frenz,
I want to display all the dates and day of the given year and month.
For ex; if i choose 2007 and select the month January, i want to generate all the dates for this selection
1/1/2007
2/1/2007
....
...
..
31/1/2007,
and the day name (monday,tuesday ...) for all the generated dates. Also, need to check for the leapyear, and generate the dates accordingly. Pls provide some kind-a help. its urgent. I'm able to generate the dates, but need to display the dayname and chk for leap year.
Cheers,
jai
2 3319 iburyak 1,017
Recognized Expert Top Contributor
Try this:
[PHP]Declare @year int, @month int, @StartDate datetime, @EndDate datetime
Declare @Date datetime
SET @year = 2008
SET @month = 2
SET @StartDate = cast(cast(@mont h as varchar(10)) + '-1-' + cast(@year as varchar(10)) as datetime)
SET @EndDate = dateadd(m,1,@St artDate)
DECLARE @temp TABLE (Date_Time varchar(50))
SET @Date = @StartDate
While @Date < @EndDate
BEGIN
INSERT INTO @temp
SELECT DATENAME (dw, @Date) + ', ' + convert(varchar (30), @Date, 110)
SELECT @Date = dateadd(d,1, @Date)
END
SELECT * from @temp[/PHP]
Don't worry about leap year it will be handled with internal calendar.
Good Luck.
Hi iburyak,
Thanks for your help. Sorry for the late reply. i was also working on the code and got the desired output. Once again, thank you.
Cheers,.
jai
Try this:
[PHP]Declare @year int, @month int, @StartDate datetime, @EndDate datetime
Declare @Date datetime
SET @year = 2008
SET @month = 2
SET @StartDate = cast(cast(@mont h as varchar(10)) + '-1-' + cast(@year as varchar(10)) as datetime)
SET @EndDate = dateadd(m,1,@St artDate)
DECLARE @temp TABLE (Date_Time varchar(50))
SET @Date = @StartDate
While @Date < @EndDate
BEGIN
INSERT INTO @temp
SELECT DATENAME (dw, @Date) + ', ' + convert(varchar (30), @Date, 110)
SELECT @Date = dateadd(d,1, @Date)
END
SELECT * from @temp[/PHP]
Don't worry about leap year it will be handled with internal calendar.
Good Luck.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: David Gray |
last post by:
Greetings all,
Quick newbie type question:
I would like to be able to trap non-numerical data entered into a
textbox via CTRL+C and/or Shift+Insert.
I realise that this data can be validated using the TEXTn_validate
event but I would like to stop the user before it gets that far.
|
by: Amy G |
last post by:
I have seen something about this beofore on this forum, but my google search
didn't come up with the answer I am looking for.
I have a list of tuples. Each tuple is in the following format:
("data", "moredata", "evenmoredata", "date string")
The date string is my concern. This is the date stamp from an email.
The problem is that I...
|
by: Thomas W |
last post by:
I'm developing a web-application where the user sometimes has to enter
dates in plain text, allthough a format may be provided to give clues.
On the server side this piece of text has to be parsed into a datetime
python-object. Does anybody have any pointers on this?
Besides the actual parsing, my main concern is the different locale
date...
|
by: F |
last post by:
Hi
I have posted the question few days back about problem in inserting the
dates in SQL server and thankful to them who replied.
That was solved and this is a nice solution.
http://www.aspfaq.com/show.asp?id=2023
Now I am facing another problem.
I have to get data between two dates. That dates user has to provide and in
|
by: Richard Hollenbeck |
last post by:
I'm trying to write some code that will convert any of the most popular
standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan
1908) and compare the first with the second and calculate days, months, and
years. This is not for a college course. It's for my own personal
genealogy website. I'm stumped about the code. I'm...
| |
by: Andy Dingley |
last post by:
I'm using this at present:
<p title="Publication date" ></p>
Works fine on screen, but Fangs/Jaws just reads it as "left bracket
twenty-eight slash zero slash two thousand five fifteen colon zero right
bracket" Really it needs something more to indicate that it _is_ a
date.
The brackets would be better done with CSS, :before and...
|
by: David |
last post by:
I'm new to DB2 and I need to write a query that will allow me to find
specific dates instead of me having a date range asked for, I want it to be
calculated.
I've done this in Access by coding visual basic scripts and making monthly
reporting automatic. No longer having to change 15 queries to match
specific date ranges for the previous...
|
by: Russell |
last post by:
I have an assignment that I have to complete. I have to write a
windows app in C#. Here is the spec:
1/ Date Comparison
Build a program that will find the number of days between two dates.
You CANNOT use the inbuilt date functions or the DateTime Type. Your
program should work with any date between 1900 and 3000.
Here are your...
|
by: Kentor |
last post by:
does anyone know of a script that would produce a calendar starting
from todays date with checkboxes next to every day of the month so that
the user is able to check it in case of an event for that day...
without specifying what the event is... just a simple checkbox..
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |