PC Review


Reply
Thread Tools Rate Thread

Cdate does not help

 
 
jodleren
Guest
Posts: n/a
 
      19th Mar 2010
Hi

I have a date, in format dd.mm.yyyy and cdate crashes when
transforming the data in to a date type - I want to subtract 15 days
from it'
Excel 2007 help sucks, it does not give anything - I want to use my 3
strings (d m and y) to create a date variable, then subtract 15. Like
in Delphi, "EncodeDate(y,m,d)"
Also the help does not give anything bright on setting the date
(format) again, so.... my ugly and non working sllution:

dStartDate = CDate(sBeginDate) - 15
sStartDate = GetFormattedNumber(Day(dStartDate), 2) & "." &
GetFormattedNumber(Month(dStartDate), 2) & "." &
GetFormattedNumber(Year(dStartDate), 4)

Any suggestions?

Sonnich
 
Reply With Quote
 
 
 
 
Ron Rosenfeld
Guest
Posts: n/a
 
      19th Mar 2010
On Fri, 19 Mar 2010 02:36:47 -0700 (PDT), jodleren <(E-Mail Removed)> wrote:

>Hi
>
>I have a date, in format dd.mm.yyyy and cdate crashes when
>transforming the data in to a date type - I want to subtract 15 days
>from it'
>Excel 2007 help sucks, it does not give anything - I want to use my 3
>strings (d m and y) to create a date variable, then subtract 15. Like
>in Delphi, "EncodeDate(y,m,d)"
>Also the help does not give anything bright on setting the date
>(format) again, so.... my ugly and non working sllution:
>
> dStartDate = CDate(sBeginDate) - 15
> sStartDate = GetFormattedNumber(Day(dStartDate), 2) & "." &
>GetFormattedNumber(Month(dStartDate), 2) & "." &
>GetFormattedNumber(Year(dStartDate), 4)
>
>Any suggestions?
>
>Sonnich


If I understand you correctly, perhaps:

========================
Option Explicit
Sub TestDate()
Dim d As Long, m As Long, y As Long
Dim dStartDate As Date

d = 13: m = 1: y = 2010

dStartDate = DateSerial(y, m, d)

Debug.Print dStartDate, dStartDate - 15
Debug.Print Format(dStartDate, "dd.mm.yyyy"), _
Format(dStartDate - 15, "dd.mm.yyyy")

End Sub
====================================

--ron
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of CDate Nigel Microsoft Access External Data 2 12th Aug 2009 04:23 PM
cdate cj2 Microsoft VB .NET 6 25th Feb 2009 04:06 PM
Re: cdate Teemu Keiski Microsoft ASP .NET 0 3rd Jul 2004 04:34 PM
CDate problem David Schwartz Microsoft VB .NET 12 9th Feb 2004 02:38 PM
Re: Problem with CDATE() in .NET Armin Zingler Microsoft VB .NET 0 25th Sep 2003 04:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 PM.