473,513 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date conversion

Hi!

I have a little problem - i have an integer value with contain a number of
some day in current day (for example 56) - and my problem is - how can i
caonvert this integer value to DateTime (for example 33 = 02.02.2004)? I
want to reverse function to DateTime.DaysOfYear

Thanks

--
Pozdrawiam serdecznie!

--
Piotr Karwatka
-- pi************@aktywni.pl, pi***@amigo.pop.pl
-- http://amigo.pop.pl
Nov 18 '05 #1
4 1128
May be like this?

// C#
DateTime x = new DateTime (DateTime.Now.Year, 1, 1);
x = x.AddDays (<your day count>-1);
// x now holds DateTime for <your day count>

"Piotr Karwatka" <pi************@amigo.pop.pl> wrote in message
news:cm**********@nemesis.news.tpi.pl...
Hi!

I have a little problem - i have an integer value with contain a number of
some day in current day (for example 56) - and my problem is - how can i
caonvert this integer value to DateTime (for example 33 = 02.02.2004)? I
want to reverse function to DateTime.DaysOfYear

Thanks

--
Pozdrawiam serdecznie!

--
Piotr Karwatka
-- pi************@aktywni.pl, pi***@amigo.pop.pl
-- http://amigo.pop.pl

Nov 18 '05 #2
Piotr Karwatka wrote:
Hi!

I have a little problem - i have an integer value with contain a
number of some day in current day (for example 56) - and my problem
is - how can i caonvert this integer value to DateTime (for example
33 = 02.02.2004)? I want to reverse function to DateTime.DaysOfYear

Thanks

--
Pozdrawiam serdecznie!


How about this
- start with jan 1st of your year
- add (number-1) days

public DateTime ReverseDaysOfYear(int year, int days)
{
DateTime dt = new DateTime(year, 1, 1);
dt = dt.AddDays(days-1);
return dt;
}
Hans Kesting
Nov 18 '05 #3
Time interval is represenred by TimeSpan structure. You can create a
timespan for the number of days you need and than add it to an instance of
DateTime structure preset to to the beginning of the year.

Eliyahu

"Piotr Karwatka" <pi************@amigo.pop.pl> wrote in message
news:cm**********@nemesis.news.tpi.pl...
Hi!

I have a little problem - i have an integer value with contain a number of some day in current day (for example 56) - and my problem is - how can i
caonvert this integer value to DateTime (for example 33 = 02.02.2004)? I
want to reverse function to DateTime.DaysOfYear

Thanks

--
Pozdrawiam serdecznie!

--
Piotr Karwatka
-- pi************@aktywni.pl, pi***@amigo.pop.pl
-- http://amigo.pop.pl

Nov 18 '05 #4
Thanks! That's that what i was looking for!

Użytkownik "Shiva" <sh******@online.excite.com> napisał w wiadomo¶ci
news:OP**************@TK2MSFTNGP10.phx.gbl...
May be like this?

// C#
DateTime x = new DateTime (DateTime.Now.Year, 1, 1);
x = x.AddDays (<your day count>-1);
// x now holds DateTime for <your day count>

"Piotr Karwatka" <pi************@amigo.pop.pl> wrote in message
news:cm**********@nemesis.news.tpi.pl...
Hi!

I have a little problem - i have an integer value with contain a number
of
some day in current day (for example 56) - and my problem is - how can i
caonvert this integer value to DateTime (for example 33 = 02.02.2004)? I
want to reverse function to DateTime.DaysOfYear

Thanks

--
Pozdrawiam serdecznie!

--
Piotr Karwatka
-- pi************@aktywni.pl, pi***@amigo.pop.pl
-- http://amigo.pop.pl

Nov 18 '05 #5

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

Similar topics

3
3719
by: praba kar | last post by:
Dear All, I have doubt regarding date string to time conversion function. In Python I cannot find flexible date string conversion function like php strtotime. I try to use following type function 1) parsedate function failed if a date string like below format "16-MAY-2005 01:26" 2)parsedate_tz function also failed if a date string
1
3581
by: Riley DeWiley | last post by:
I have an UPDATE query that is always setting 0 records. When I cut and paste the SQL into Access and use it, it fails in the same way unless I coerce the date fields to be '=now()', in which case it works. I never get errors, and if I don't try to update the date fields, I always update the expected number of rows (1). When I do date...
1
1631
by: Franck | last post by:
Hi, 'm gettin mad about date conversion. Here is the point. Got and add-in for Excel which call functions from a web service (on a remote server) The remote server has regional settings set to "en-UK" and date to dd/MM/yyyy. (I'can't change it !)
10
1660
by: melissa.nava | last post by:
Here is my code: ***** Public Property DOB() As Date Get Try DOB = (msBirthMonth + "/" + msBirthDay + "/" + msBirthYear)
8
8369
by: no_spam_for_gman | last post by:
Hi, Has anybody ever created a DB2 date function to convert a JDEdwards date to a db2 date? Example: September 28 is 106271 in JDEdwards.
44
10130
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
10
48697
by: =?Utf-8?B?TWlrZQ==?= | last post by:
I have a string variable containing a date formatted as YYYYMMDD For example - Dim x as string = "20070314" If I try to perform a type conversion as follows I get an error: Dim y as Date = CDATE(x) How can I perform a type conversion for the date format YYYYMMDD? Thanks.
1
3218
by: vadala | last post by:
The requirement is to send start data and end date from java to UI (.net) for a functionality. We are setting the time in java (1.5) before handing it over to WebService (sending to UI ) in "ASIA/KUALA_LUMPUR" (MYT) TIMEZONE. OS WIN-XP Strangely UI receives a different date. java side UI side
7
2999
by: bruce.dodds | last post by:
Access seems to be handling a date string conversion inconsistently in an append query. The query converts a YYYYMM string into a date, using the following function: CDate(Right(,2) & "/1/" & Left(,4)) I entered the string "200715" in a record to test an error condition.
2
5131
by: RN1 | last post by:
A TextBox displays the current date (in dd/mm/yyyy format) & time when a user comes to a page (e.g. 15/10/2008 1:36:39 PM). To convert the date into international format so that the remote server doesn't generate any error, this is what I am doing: --------------------------- Dim strSDate As String Dim strSTime As String Dim strStartDT As...
0
7270
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7543
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 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...
0
5703
agi2029
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...
0
3252
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...
0
1612
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
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
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...

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.