Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Date Format Changes When Saving


Hi

I've searched the forums here and can't find a specific solution.

I'm saving a sheet as a csv file. The sheet has a column of dates which is formatted to dd/mm/yyyy.
When I save the sheet as a csv manually I get the dates in dd/mm/yyyy format.
When I save the sheet using the vb code I get the dates in mm/dd/yyyy format.

If it helps any, here's the line of code that's doing the saveas

xDataSheet.SaveAs FileName:=sLoc, FileFormat:=xlCSV


I need to have the dates in a specific format for the next phase to work correctly, anyone got any ideas why it changes and / or what I can do about it


Any help much appreciated as I can't afford to lose any more hair

TIA
Dave




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Date Format When Saving Excel From VB
I use Excel automation from VB to open a Worksheet and save it as text, the save method writes date with a strange behavior. My Excel ver is 2000.

If my PC regional settings are dd/mm/yyyy and the excel cell format is dd/mm/yyyy, the resulting field goes mm/dd/yyyy. All the other 3 combinations (PC dd/mm and cell dd/mm; PC mm/dd and cell mm/dd; PC mm/dd and cell dd/mm) goes ok.

I need to run the code against all 4 combinations.

Is there any way to force a right formatting?

The code is:

Set objExcApp = GetObject("", "Excel.Application")
Set objExcWb = objExcApp.Workbooks.Open("mydata.xls")
Set objExcWs = objExcWb.Worksheets("sheet1")
objExcWs.SaveAs FileName:="mydata.txt", FileFormat:=xlText, CreateBackup:=False

Change Short Date Format To Long Date Format (windows Api?)
i want that when i load my program, it will change the date settings in my computer (short date to long date). How can i do that?

DATE Problems - Change Date Format To European, Get Current Date, Subtract 2 Dates?
Need someone to point me in the right direction/start me off with this please as I am quite clueless on it at present...

I need something that can successfully subtract two dates...


eg. calculate the difference between the current date
02/04/04 (2nd April 04) and 29/03/04 (28th March 04)
...
which will then output a result of 5 days


So what I need to know is...

1.
I need to know how to get the current date from the system clock

2.
I must somehow get my date function converted into European date format (as at present it is in USA format ie. 2nd April 04 is 04/02/04 like April 2nd 04 which is not good!)

3.
and then I must actually SUBTRACT the 2 dates (the current date and a date that is given) from each other to give an integer which I can then use (ie. a value like 5 or 15).


But I have little idea how to go about this


Can anyone please start me off?

DATE Problems - Change Date Format To European, Get Current Date, Subtract 2 Dates?
Need someone to point me in the right direction/start me off with this please as I am quite clueless on it at present...

I need something that can successfully subtract two dates...


eg. calculate the difference between the current date
     02/04/04 (2nd April 04) and 29/03/04 (28th March 04)
     ...
     which will then output a result of 5 days


So what I need to know is...

1.
I need to know how to get the current date from the system clock

2.
I must somehow get my date function converted into European date format (as at present it is in USA format ie. 2nd April 04 is 04/02/04 like April 2nd 04 which is not good!)

3.
and then I must actually SUBTRACT the 2 dates (the current date and a date that is given) from each other to give an integer which I can then use (ie. a value like 5 or 15).


But I have little idea how to go about this


Can anyone please start me off?

DATE Problem - Formatting US Date MM/DD/YY To European Date Format DD/MM/YY
I have a problem whereby the user must enter a date into a field...

The system changes the date format to US standard which is MM/DD/YY
but I need to change the format to DD/MM/YY (European standard)


I have done this using the Format function, but I still have a slight problem
Format(mydate,"dd/mm/yy")

doesnt account for all dates...

for example...
if I enter 31/03/04 this is fine, it will accept it as that

However, if I enter 02/04/04 (todays date - 2nd April 04), it will change it to 04/02/04



Any ideas how I can counter this from happening?

DATE Problem - Formatting US Date MM/DD/YY To European Date Format DD/MM/YY
I have a problem whereby the user must enter a date into a field...

The system changes the date format to US standard which is MM/DD/YY
but I need to change the format to DD/MM/YY (European standard)


I have done this using the Format function, but I still have a slight problem
Format(mydate,"dd/mm/yy")

doesnt account for all dates...

for example...
if I enter 31/03/04 this is fine, it will accept it as that

However, if I enter 02/04/04 (todays date - 2nd April 04), it will change it to 04/02/04



Any ideas how I can counter this from happening?

Setting Long - Short Date Format In Date Time Settings
How can i set the Date Time Setting Format in Control Panel

i m usiing window Xp


also i want the date format in dd/MM/yyyy

Date Conversion As Oracle Database Date Default Format
Select sysdate from dual ; //oracle database
The result is : 28-AUG-04

How to convert “date” in vb to the above format?

Using below statement :
FormatDateTime(Date, vbLongDate) // Saturday, August 28, 2004

Then, combine with string functions (such as instr, left, mid, etc) can be achieved the desired result.

Any shortcut than above mentioned?

Thanks.
vb999

Date Format, Count No. Of Days & Highlight Date In Calendar
<html><div style='background-color:'><DIV>
<P>Hi all,</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Happen to visit this website accidentally and found that it’s very useful to VB beginner like me. <SPAN style="mso-spacerun: yes"> </SPAN>I have the following problems and would appreciate your kind assistance to enlighten me.<SPAN style="mso-spacerun: yes">  </SPAN>Attached is my file for your checking.<SPAN style="mso-spacerun: yes">  </SPAN></P></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> <?XML:NAMESPACE PREFIX = O /><O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; tab-stops: list .5in; mso-list: l0 level1 lfo3">1)<SPAN style="FONT: 7pt 'Times New Roman'">      </SPAN>Sometimes, the number of days is incorrect with a big figure (e.g from 1 to 30 Apr) or even a negative figure after I change the system’s date format from “mm/dd/yyyy” to “dd/mm/yyyy”.<SPAN style="mso-spacerun: yes">  </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"> <O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; tab-stops: list .5in; mso-list: l0 level1 lfo3">2)<SPAN style="FONT: 7pt 'Times New Roman'">      </SPAN>In calculating the number of days, I need to exclude Sunday.<SPAN style="mso-spacerun: yes">  </SPAN>By using the “WeekDay (Calendar1) = 7 “ method, I still didn’t get the correct result.<SPAN style="mso-spacerun: yes">  </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> </P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><O:P>      3)  How to highlight a certain date in calendar with different colour to indicate it's a public holiday ? </O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><O:P></O:P> </P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Many thanks in advance.<SPAN style="mso-spacerun: yes">  </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> <O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Best regards,</P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">YC </P>
<DIV></DIV>
<DIV></DIV>
<P><BR><BR></P>
<DIV></DIV>
<DIV></DIV></div><br clear=all><hr>Add photos to your e-mail with <a href="http://g.msn.com/8HMVEN/2746">MSN 8.</a> Get 2 months FREE*.</html>

Date && Time Values In Date And String Format Differ
The program (debug) output below lists the last modification time of two files. File 1 is stored on a NTFS medium, file 2 sits on a FAT medium.

In order to be able to compare these dates, I need to round the odd seconds of the NTFS file up (FAT files have only even second values).

The lines after the file headers show the date & time value before and after the rounding, in date, double precision and string format.

file 1 (NTFS)
= 2005-07-12 08:57:09 = 38545,3730208333 = 2005-07-12 08:57:09
after rounding up
= 2005-07-12 08:57:10 = 38545,3730324074 = 2005-07-12 08:57:10

file 2 (FAT)
= 2005-07-12 08:57:10 = 38545,3730324074 = 2005-07-12 08:57:10

The strange thing is that when comparing these values, they appear to be different (!) both in date and double data format, not in string format.

2005-07-12 08:57:10 > 2005-07-12 08:57:10 (date format)
38545,3730324074 > 38545,3730324074 (double precision format)
2005-07-12 08:57:10 = 2005-07-12 08:57:10 (string format)

Any idea where this difference comes from?

Rounding up was done with DateAdd.

VB version 6, on XP.
Boiled down code has been attached.

Making Sure The User Enters A Date In Date Format
How do I ensure a user enters text in a textbox in date format? i.e. when the user enters into the textbox it automatically has:
--/--/--
and only allows the user to entera valid date.

How To Set The Date Into Long Date Format In The Regional Settings?
how can i SET the date into long date format (regional settings)?

i want that once my form is loaded, it will automatically SET the date in the regional settings into long date format.

Getting Numbers In Date Field Into Date Format???
in my access db i have an old table and the dates were never formatted eg its just 791023 as in 23 of oct 1979 so i had to change that to get it in date format so i did this using a query

UPDATE history_date SET history_date.theDate = format([theDate]," mm/dd/yy");

like it worked and put in the slashes but the date is different
it came out 01/25/55 when the date was originally 641027
why is it changing it ???
like i tried diff format like yy/mm/dd and still the same...
confused!!please help if u know anything...

Format String To Date Format And ....
Question one,
If a user types 4/5/03 into a textbox, how do I format this to this date style - 04/05/03?

They may type it as I want, or they may type it like the above, so I need to make sure before I do part two, below, that it is in the correct format.

Part two,
How can I compare the month part of the date (05) with a Month name (e.g. September) in a Flexgrid. I know I can use the textmatrix to get the name of the month. Would the best way be to use a select case to compare the months?

Format String To Date Format And .....
Question one,
If a user types 4/5/03 into a textbox, how do I format this to this date style - 04/05/03?

They may type it as I want, or they may type it like the above, so I need to make sure before I do part two, below, that it is in the correct format.

Part two,
How can I compare the month part of the date (05) with a Month name (e.g. September) in a Flexgrid. I know I can use the textmatrix to get the name of the month. Would the best way be to use a select case to compare the months?





Edited by - andy99 on 9/25/2003 9:57:39 AM

Valid Date/Date Format
You guys were probably doing this one in third grade...

I have a textbox on a form in which a user enters a date. I want the user to always enter the date in the following format: mm/dd/yy

When they click OK, how can I check to make sure it's a valid date and it's in the format I want, no other format?

Thanks!!

Empty Date && Date Format
I have in my table a field where I have now a date like
#01-Jan-2004#
But, for a specific reason, I want to delete that date and leave the field empty.
How can I do that? Is there any constant for the "empty date"?
If I try #00-00-00# I get an error.

And another question:
Is there any chance to set the date format? I don't want to depend on computer settings!!! I want to be sure that if the user will write in a text box
"02-03-2004"
this will be "02-Mar-2004" and not "Feb-03-2004"

Date Format But Not Current Date HOW?
I am new to VB. Work with VB5 Enterprise.

I think this should be simple, but I cannot figure it out:

How do I create a text-box in which the user can write a random date that is not today's date. And still keep the date format?

Example: User inputs 12122009 and I want textbox to change into: 12-12-2009 or 12:12:09 or 12-12-09 or 12:12:2009.

The change should be instant or at the latest at "lost focus".

All the examples I have found work with the current date.

Any ideas?

All the best
Svanholm



How To Get The Right Date Format After Adding A Date
Hi ,

The below is the Code in the Timer. The Purpose is to when the Time Reaches the process should done. The process is

Reading a Encrypted text from the file named ImpDate.TXT, the Text is the date and its Format Is (“MM/DD/YYYY HH:MM:SS AM/PM”).

After reading it I am storing it in a string. Then I need to add one day with Date which I get and Decrypted. Then again I will encrypt it and over write the ImpDate.TXT File.

Private Sub Timer1_Timer()

MyTime = Format(TimeValue("12:05:50 PM"), "HH:MM:SS AM/PM")
CurTime = Format(Time, "HH:MM:SS AM/PM")

If MyTime = CurTime Then

‘’ Reading the Encrypted Text from the File
    Open "C:chsImpDate.TXT" For Input As #1
    While Not EOF(1)
    Line Input #1, st
    Wend
    Close #1
   
 Secret$ = st
  Password$ = "vehiclesystem"
‘’Decrypting the Encrypted Text and add one day with it and again I have Encrypt and Store. For testing whether the one day is added or not, I write it in a file DecDate and checked.

  Call Decrypt(Secret$, Password$)
   sts = Format(st, "MM/DD/YYYY")
       Dim nFile As Integer
    nFile = FreeFile
    Open "C:chsDecDate.TXT" For Append Shared As #nFile

    Print #nFile, sts
    Close #nFile
End If
End Sub

The problem is I am getting the wrong date is coming as below

01/27/1900 12:00:00 AM

tried in various ways but not coming the correctly.

Thank you very much,
Chock.

How To Validate A Date When Date Format Is Different
How validation of date whould be done where date format is "dd/MM/yyyy" and windows date format is "MM/dd/yyyy"

Format Date In Long Date
In VBscript, i want to format date in long date like : 09/06/98 --&gt; june 9, 1998

Saving In Csv Format With ;
HI;

i have a big problem.
i'm in excel 2002 and i want to save a file in csv format with ";" using a macro.
I've recorded my macro => ok but then i use this macro it doesn't work : there are "," instead of ";"

This is my code :

ActiveWorkbook.SaveAs Filename:=fichier3, FileFormat :=xlCSV, CreateBackup:=False

Can someone help me ?
thanks

Saving In This Format...
How can I make it so when user saves it saves into this format:

"Hey", "Jose", 1

So when the text file is opened it is in that format.

Saving To XLS Format
Hi,

¿Is it possible to find info on how to create XLS (M$ Excel) files here or some place else?

Saving In Gif/jpeg Format
HI everyone,

Can anybody tell me how to save a image in a gif or/and jpeg format through vb code.

Saving A File In UTF-8 Format
Hello all. I'm looking for some help for a problem that's been stumping me for some time now. I'm currently working on a project at work using Excel VB whereby I create a configuration file for a program that we use to monitor parameters in a controller module. I've successfully completed 99% of the work needed. However, it seems I've run into an interesting problem with VB that I've never encountered before. When I am saving the config file, VB seems to default to saving it with ANSI encoding. This is normally all well and good except for the fact that the program that reads in the config file doesn't like ANSI and will only read files with UTF-8 encoding. Does anyone know how I can go about saving these files in UTF-8 format? I've looked through the help files in Excel and and I haven't found anything. Thanks in advance!

Saving In Word Format
Hi Y'all!

In my App, I'm printing some info into a TXt file. The probles is that my boss wants me to print (store) them in WORD format (*.doc)!

How do I do that?

Regards!
Ales Zigon

Saving Richtextbox Format To Doc
I can save stuff from the richtextbox to a word .doc but it doesn't carry over the format like the the bolds a colors and such. Is there something I need to add in my code?!?! Now I'm opening a .dot (word templete) and saving everything to that as a .doc and all the info comes out fine and its bolded and color in the RTB I dont know if theres a command I have to set to make the bolds and colors come out on the .doc?? Any Ideas?

Saving Txt File In Ms-dos Format
Hey

Im writing some data into a txt file, but i need it to save in Ms-Dos format, and not in the standard format that windows 2k use.

I need to do this cuz i have some special signs in danish language, that aint allowed in the txt file.

I tryed to do it by opening Wordpad and that works now i just need to make it save the file in the right format

This is the code to open the file:

Shell "C:programmerwindows NTTilbehørWORDPAD.EXE C:
yhedsbrev.txt", 1

Best regards

Garn

Ps. it would be cool if it all could be done i the background so the user would see it happening

Saving To A File But Not In *.ini Format...
As far as saving information goes, all I know how to do is save information to *.ini files, which is going really good until the other day when I TRIED to make a password saver, but then I realized that even when you don't save the file as a *.ini file, you can still open it in notepad and read it off just like you would a *.ini file. My question is: how can I save information (such as passwords) to a file, and when someone opens it, all they see is "*/a.;'%" ? Also, this might be a problem for the program loading the information back, but I don't know which is why I ask. Any help would be cool, thanks.

MCI && Saving In 16bit PCM Format
I am using the MCI control to record sound from my microphone but the problem is when I click save the files are saved in 8bit PCM format. i want to save it in 16bit PCm format. What can I Do?

thanks

Saving WebPages To The *.mht Format In IE5.x
Greetings,
    Have a question but do not know whether it has been answered or not, i need to automatically save a given webpage to a *.mht file so that i could then copy it to our server. For example Write2File("http://vbcity.com/", "c: empmyfile.mht"). Is this possible in VB ? I did see some codes that saves html and pictures but what we need is something that could save as a mht file format.
Hope you guys can help me out
Thanks a million.

Saving WebPages To The *.mht Format In IE5.x
Greetings,
Have a question but do not know whether it has been answered or not, i need to automatically save a given webpage to a *.mht file so that i could then copy it to our server. For example Write2File("http://codeguru.com/", "c: empmyfile.mht"). Is this possible in VB ? I did see some codes that saves html and pictures but what we need is something that could save as a mht file format.
Hope you guys can help me out
Thanks in advance.
V.Thandava Krishna

Saving In Unicode Format?
How can i save text file with commonsavedialog, that has unicode characters? Can't save in Binary.

Saving Text Format To A File
I want to save the text in a TextBox to a file, but preserve the word wrap and spacing. I can save the text itself without a problem, but it just saves it as one long line.

When I open the text file in Notepad or a text editor, I want it to appear just like it did in the TextBox. How can I do this?

Saving Live Video In Avi Format
Hi

Ho do u save a real-time video seen on a lap-top through a USB connected webcam into a AVI format in the hard disk?

Thanks.

Saving Textbox In ANSI Format?
To let you know I am creating a text editor for perl and if you save the text using standard way of doing it the text is saved in a strange format. All the line feeds are converted into these little squares..(no idea what there called)but anyways I want to be able to save the textbox in ANSI format like how http://www.textpad.com lets you save it in ANSI format. Thats what I use right now but I want to have the specialized features of my program to do it. So anyways as I was saying I want the text to be saved in ANSI format. I'm sure this is not to hard. If anyone can help I would appreciate it.

Format Text When Saving To A File
let's say I got a 5 MB long string in memory.
I want to save it as a file with no more that 65 bytes per line.
looping sounds horrible...it takes so much time

is there a function doing this ?

Problem In Saving Html Format Plz Help Me
i save my grid as html by using html code don't want to use datareport, but want to change its html format into "rptKeyUnicodeHTML_UTF8" format how can i do that plz help me
this format is same as format


   i also just try by changing common dialog extension



               Plz help



Edited by - azeemgujjar1 on 1/16/2006 12:32:48 PM

Saving Database In Word Format
hello everyone!

      just want to ask, how can i save my database in datagrid in word format, so i can email it as a attachement.
    pls help me. i really need it.



     Rommel Christopher C. Cuya

Saving Excel Graphic As A GIF (or Other Format)
Hello,

actually I create a graphic using Excel, I put this graphic on the clipboard and I open Powerpoint to save this graphic as a GIF file. There is a direct way to do the same ?. It is possible directly from Excel to save a Graphic in a file ?

Best Regards

Alfredo DS

Saving Live Video In Avi Format
Hi there

I'm unable to save my live video (that is running in my program) into my hard disk? I am able to save still images (that I have captured) but i can't save a whole live video using VB? Any suggestions?

Thanks a lot!

Saving MSChart Contents In JPEG Format
Hi everyone,

I am able to save a MSChart contents using the method described in Microsoft Knowledge Base Article - Q197487. It is similar to the .EditCopy/.EditPate method of MSChart. It basically copies the chart into a pictureBox (using API) and then copies it into the clipboard and you can save it. I am using SavePicture to save the picture from picBox to file.

My problem is that it it does this in bmp format. I need to save it in JPEG format. Any idea how I can do this.

Thanx...

Looping Through .docs In Directory, Saving As Different Format
I found code that allows me to loop through all . doc files in a directory (C:WordTestinput, in this case). The code adds the word "test" to the end of each doc, saves the doc, then closes it.

I'm trying to modify the code so each file gets saved as HTML. But there's a line that's giving me trouble:

docDoc.SaveAs FileName = test1a.htm, FileFormat:=wdFormatHTML

I'm pretty certain (okay, I'm guessing) a variable needs to go in place of "test1a.htm," since the code is looping through all files instead of dealing with only a single file, but all my attempts so far have bombed out.

Any help?

Thanks.

Here's the code:

Sub LoopThroughFilesInFolder()
Dim i As Integer
Dim docDoc As Document

With Application.FileSearch
.LookIn = "c:WordTestinput"
.FileName = "*.doc"
.Execute
For i = 1 To .FoundFiles.Count

' Message box for informational purposes only
MsgBox "File #" & i & " is " & .FoundFiles(i)

'opens files individually
Set docDoc = Documents.Open(FileName:=.FoundFiles(i))

'change the doc and save it
docDoc.Range.InsertAfter "test"
docDoc.SaveAs FileName = test1a.htm, FileFormat:=wdFormatHTML
docDoc.Close (wdSaveChanges)
Next i
End With
End Sub

Saving RichTextBox Format (RTF) To MSDE/SQL Server
Hi All,

Just wondering, is it possible to save the contents of a RichTextBox, formatting and all, to a SQL Server DB so that it may be displayed correctly in the future?

At present I have saved the RTB formatted data to the DB with the aid of .textRTF and can display it again in a form without any issues. My problem lies in exporting the RTB info to a Word Doc. Again this is no problem. The problem lies in that while the VB form can reconstitute the RTB data to display it properly, I cannot find a way to reconstitute the RTB info when exporting to Word.

I cannot export the RTB info as an image as I need to be able to edit the resulting Word doc.

Any suggestions anyone on how to display the RTF info correctly in Word?

Thanks and Happy New Year!

Gb

Saving A File In Rich Text Format?
Hi,

I'm currently making a program which is much like Word, and I have decided to save all of the documents as a RTF file. I have worked out the common dialogue bit for saving, but when I paste a picture into the Rich Text Box, and save it, the picture isn't there! and the font that I have selected isn't there! It's always Courier New!!

Any help would be greatly appreciated,



Chris

Saving To Jpeg Format Form Picturebox?
I know it's probably not easy to do this, especially when the picturebox can't be seen...

I've tried saving an image in a picturebox as a BMP and the using bmp2jpeg.dll to convert it to a smaller jpeg file, but, this dll has memory issues, it never releases the memory it uses to load and convert images.

I need to run this in a loop, so speed would be nice, do you have any ideas?

* RESOLVED * Saving To An .ini File (not Typical Format Of X=x)
I want to save to a ini file of the following format:


VB Code:
autoframeskip           1frameskip               0waitvsync               0triplebuffer            0window                  0ddraw                   1direct3d                0hwstretch               1


I've saved to typical ini files before using downloadable ReadINI and WriteINI functions, but not with tabbed spacing like this one.

TIA

OnErrOr's GDI+: Possibility Of Saving Images In TIF Format With Compression
I would like to ask, how about possibity to control compression of TIF images saving to files by means of GDI+. Is it possible to save in TIF format and to choose compression factor? I think TIF uncompressed or compressed, for example, according to TIFF 6.0 Group4 specification? And what compression is used (if any) by default?

Thanks in advance for Your answer.
Regards.
MilanJ

Copyright © 2005-08 www.BigResource.com, All rights reserved