# [web] SQL: Date by numbers

This topic is 4988 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is actually very loosely related to what I am trying to do, but I think it may come up at some point [smile] Say I have a Database with the fields:

Day  | Week
---------------
1   |  1
3   |  2
6   |  3

How could I format this to see the first record (1-1) as the first day of the second week of the year, and output it as '2/1/05'? Is this even possible? Cheers!

##### Share on other sites
I don't really get what your asking here, but i'll give it a go anyway :) if you know that Day 1 Week 1 is the 2/1/05 then it would be just a simple matter of figuring out the number of days that make up the next entry.

That is day 3 week 2 would be 3 days + 7 days ( 1 week ) = 10 days, which then gets added to your original date to get the date for this entry. in this case it would be the 12/1/05.

Which database are you using to do this if your using ORACLE or SQL Server it would be possible to do the date addition using either PL/SQL or T-SQL but i would suggest that this calculation is done programmatically so you can support other DB's too.

I hope this helps and i haven't got the wrong end of the stick :)

##### Share on other sites
That sounds very close to what I want to do.

I keep forgetting to say each time I post SQL questions, but I am using Access.

##### Share on other sites
If you are using access then a simple DateAdd function will suffice as long as you know what Day 1 week 1 date is its just a simple matter of finding the number of days to be added and then doing DateAdd("d", NumDays, Day1Week1Date) to get the required date. You could even create a calculated column that calculates this value for each row using the dateadd function its quite easy. Check out this page for some additional help

m\$ access date help

##### Share on other sites
rofflecopters! That was simpler that I thought!

Thanks mate [smile]

no worries :)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634047
• Total Posts
3015231
×