convert integer to date

convert integer to date

Page 1 of 1

8 Replies - 5996 Views - Last Post: 16 February 2010 - 08:29 AM Rate Topic: -----

#1 Guest_Adil Kara*


Reputation:

convert integer to date

Posted 15 February 2010 - 08:06 AM

hi all
i know this function
format(date,"y")
output= 46

but how can i learn 46 to date?

format(46,"dd.mm.yyyy") = 14.02.1900

but i want for this year (2010)

i dont want add any number to 46,
40178 = 01.01.2010 but i dont want this

i want learn for this year

example: for 2015 i want use same function, how can i do it?

Sorry for my bad english.

please help

Is This A Good Question/Topic? 0

Replies To: convert integer to date

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: convert integer to date

Posted 15 February 2010 - 09:07 AM

do you try using CDate
Function CDate(Expression) As Date
Member of VBA.Conversion
Converts an expression to a Date

This post has been edited by NoBrain: 15 February 2010 - 12:10 PM

Was This Post Helpful? 0
  • +
  • -

#3 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: convert integer to date

Posted 15 February 2010 - 07:27 PM

Quote

y Display the day of the year as a number (1 366).


So you are not returning the year with that code but returning the day of the year...

So what you need to do is use either of these...

Quote

yy Display the year as a 2-digit number (00 99).
yyyy Display the year as a 4-digit number (100 9999).


in your format function...

and you can find this information in help under the see also link > User-Defined Date/Time Formats (Format Function)



Good Luck
Was This Post Helpful? 0
  • +
  • -

#4 Guest_Guest*


Reputation:

Re: convert integer to date

Posted 16 February 2010 - 02:42 AM

i try cdate.

i search user defined date format but i cant find,
its really important for me.
Was This Post Helpful? 0

#5 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: convert integer to date

Posted 16 February 2010 - 02:52 AM

well we rly dont understand what you want (me for sure) you want to cut the year only from a date or what. if so use format(dDate,"yyyy") if dDate contain "16.02.2010" then format() function will return 2010. but if you take the year only how do you think the compiler will know the whole date?
Was This Post Helpful? 0
  • +
  • -

#6 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: convert integer to date

Posted 16 February 2010 - 06:32 AM

Type in format and press F1, click on see also, when dialog pops up, select appropriate title I gave you and select ok.



Good Luck
Was This Post Helpful? 0
  • +
  • -

#7 Guest_pojeck*


Reputation:

Re: convert integer to date

Posted 16 February 2010 - 07:20 AM

View PostNoBrain, on 16 February 2010 - 01:52 AM, said:

well we rly dont understand what you want (me for sure) you want to cut the year only from a date or what. if so use format(dDate,"yyyy") if dDate contain "16.02.2010" then format() function will return 2010. but if you take the year only how do you think the compiler will know the whole date?


hi
format(date,"y") = 47 for today

i want a function when i write 47
function is return me 16.02.2010

example format(47,"dd.mm.yyyy") = 16.02.1900

but i want this function for this year,
function(46,"dd.mm.yyyy") = 16.02.2010

but some times february have 29 days
if i use 1900 february is 28 and always same.

i want a function, number to date for active year..

I hope i explain my problem.

Thank u so much
Was This Post Helpful? 0

#8 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: convert integer to date

Posted 16 February 2010 - 07:41 AM

Find Days In Month
First and last day of a month
Was This Post Helpful? 0
  • +
  • -

#9 Guest_Adil Kara*


Reputation:

Re: convert integer to date

Posted 16 February 2010 - 08:29 AM

View PostNoBrain, on 16 February 2010 - 06:41 AM, said:



Private Function NumberToDate(ByVal Number As Integer) As Date
Dim BasTarih As Date
BasTarih = CDate("01.01." & Year(Date))
NumberToDate = DateAdd("d", Number, BasTarih)
End Function

i wrote a fucntion
i think this function is true
isnt it?
Was This Post Helpful? 0

Page 1 of 1