473,406 Members | 2,259 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,406 software developers and data experts.

year to date conversion

hi ,

i have a string sYear = 2008;
i need search from the database the results which are in the year 2008.

so how can i convert 2008 to this format

sDateFrom = "2008-01-01";
sDateTo = "2008-12-31";

thanks in advance...
raj
Oct 13 '08 #1
2 1281
JosAH
11,448 Expert 8TB
hi ,

i have a string sYear = 2008;
i need search from the database the results which are in the year 2008.

so how can i convert 2008 to this format

sDateFrom = "2008-01-01";
sDateTo = "2008-12-31";

thanks in advance...
raj
If you just want String representations of the first and last day of the year you can
do this:

Expand|Select|Wrap|Line Numbers
  1. int year= ... ;
  2. String sDateFrom= year+"-01-01";
  3. String sDateTo= year+"-12-31";
  4.  
Otherwise have a look at the (Gregorian)Calendar class.

kind regards,

Jos
Oct 13 '08 #2
Most DBs now support date parsing in the queries. Some to_char for Oracle. check DB documentation as well.
Oct 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Hunter | last post by:
>>> from datetime import date >>> dt = date(1005,1,1) >>> print dt.strftime('%Y') Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: year=1005 is before 1900; the...
7
by: Fendi Baba | last post by:
The function is called from opencalendar(targetfield). Thanks for any hints on what could be the problem. .............................................................. var...
4
by: oyvgi | last post by:
I was wondering if it there is an "easy" way to get the dd-mm-yyyy from ww-yyyy. I would like to get, for example the first day (date-month-year) in the week i specify. Found plenty of ways to...
12
by: Mark | last post by:
I feel embarassed asking such a simple question --- Year(Date()) returns 2004; I want only the last two digits. Format(Year(Date()),"yy") returns 05. How do I get 04? Thanks! Mark
2
by: Douglas | last post by:
I have a Vehicle MOT field in my table which i have as a Date field I dont really want to hold the year, just 'dd mmm' as MOTs are the same date every year. I have the field on my form as a...
6
by: PMBragg | last post by:
Thank you everyone that helped me with my DateSerial question. I really do appreciate it. Now my accountant has told I need to pull the inventory for just the year I'm depreciating. Is there a way...
2
by: Bernd Hohmann | last post by:
Dear collegues, small query problem. A table (simplified example)... customer as char(5) inv_date as date amount as double
3
by: jannoergaard | last post by:
Hi I want to write a function that can return a sum for a given date range. The same function should be able to return the sum for the same period year before. Let me give an example: The...
21
Jezternz
by: Jezternz | last post by:
Okay. Simple as it sounds, but possibly complex. I have $week (which is the week in a year 1-52) and I have $year. I want to get the day of the saturday in the given $week and $year, so i want...
14
by: Tommy Jakobsen | last post by:
Hi. Is there a method in .NET that takes "year" as an argument and returns the total number of weeks in that year? For culture da-DK (Danish). Thanks in advance. Tommy.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
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...

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.