473,487 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

convert DATE to STRING format

1 New Member
Hello

I have a date format '01/01/1000' I want to convert that date to string "01012000". Please help me how do I do
that?
Feb 7 '07 #1
7 10053
dshimer
136 Recognized Expert New Member
Hello

I have a date format '01/01/1000' I want to convert that date to string "01012000". Please help me how do I do
that?
If it is a typo and you don't really want to change 1000 to 2000 then
Expand|Select|Wrap|Line Numbers
  1. DateString='01/01/1000'
  2. DateString.replace('/','')
  3. '01011000'
would do it. If you really want to add something to the year, then splitting the string and putting it back together would be necessary.
Feb 7 '07 #2
bvdet
2,851 Recognized Expert Moderator Specialist
Hello

I have a date format '01/01/1000' I want to convert that date to string "01012000". Please help me how do I do
that?
Expand|Select|Wrap|Line Numbers
  1. >>> s = '01/01/1000'
  2. >>> s = s.replace('/', '')
  3. >>> s
  4. '01011000'
Expand|Select|Wrap|Line Numbers
  1. >>> s = '01/01/1000'
  2. >>> ''.join(s.split('/'))
  3. '01011000'
  4. >>> 
Did you just want to remove the '/'?
Feb 7 '07 #3
dshimer
136 Recognized Expert New Member
If you need to add something (like 1000) then the following based on the DateString created in the previous post.
Expand|Select|Wrap|Line Numbers
  1. repr(string.atoi(DateString.split('/')[2])+1000)
Would
Split the date string at the slashes..........DateString.split('/')
return the 3rd member which is the 1000..........[2]
change the string to an int..........string.atoi()
Add 1000 to it (the int)..........+1000
change it back to a string..........repr()
Which could then be joined back to the other elements.
Feb 7 '07 #4
bvdet
2,851 Recognized Expert Moderator Specialist
If you need to add something (like 1000) then the following based on the DateString created in the previous post.
Expand|Select|Wrap|Line Numbers
  1. repr(string.atoi(DateString.split('/')[2])+1000)
Would
Split the date string at the slashes..........DateString.split('/')
return the 3rd member which is the 1000..........[2]
change the string to an int..........string.atoi()
Add 1000 to it (the int)..........+1000
change it back to a string..........repr()
Which could then be joined back to the other elements.
dshimer,

From Python 2.3 documentation:
'atoi( s[, base])

Deprecated since release 2.0. Use the int() built-in function.'

I have been severely scolded on this forum in the past for using the string module!
Feb 7 '07 #5
dshimer
136 Recognized Expert New Member
dshimer,

From Python 2.3 documentation:
'atoi( s[, base])

Deprecated since release 2.0. Use the int() built-in function.'

I have been severely scolded on this forum in the past for using the string module!
Thanks for keeping an eye on me, the vast majority of my code is written for an embedded version to add function to my CAD program. They just switched from 2.2 to 2.5 and my tendency is to just go back to things I know or the first thing that comes to mind, which are rarely the best way. Should have caught that one though.
Feb 7 '07 #6
bvdet
2,851 Recognized Expert Moderator Specialist
Thanks for keeping an eye on me, the vast majority of my code is written for an embedded version to add function to my CAD program. They just switched from 2.2 to 2.5 and my tendency is to just go back to things I know or the first thing that comes to mind, which are rarely the best way. Should have caught that one though.
No problem. What type of CAD? A Python interpreter is embedded in it? All my Python production work is executed by an embedded interpreter in SDS/2 which is 3D CAD for structural steel detailing. We are still on 2.3. Generally what type of operations do your scripts perform?
Feb 7 '07 #7
dshimer
136 Recognized Expert New Member
No problem. What type of CAD? A Python interpreter is embedded in it? All my Python production work is executed by an embedded interpreter in SDS/2 which is 3D CAD for structural steel detailing. We are still on 2.3. Generally what type of operations do your scripts perform?
It's called VrOne and is primarily for topographic mapping and collecting raw data for Geographic Information Systems. We have full access to the data for batch processing and analysis, along with a host of individual entity (lines, symbols, text) identification, attribute extraction, modification functions. Lots of helpful GUI stuff thrown in so it is possible to write from scratch any function that you think the software should have. Mine tend to run the whole range from simple time saver convenience functions, to batch data processing and analysis. Python is one of the things that makes the job really fun.
Though now I think of it I'm getting really off topic.
Feb 7 '07 #8

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

Similar topics

13
9264
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
2
39770
by: Hector A | last post by:
Hi I'm trying to convert a string that already looks like a date to a date that I can use when I pass it from java to the database. I receive the date in format yyyy-mm-dd and I need it to be a...
5
16278
by: goochey | last post by:
I'm trying to convert a Julian Date (Format "4365") into an actual calendar date in Visual Basic, can anyone help me out with this.
2
5061
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...
12
3826
by: DC Gringo | last post by:
How can I convert this pubLatest to a date with format "m/d/yyyy"? Dim pubLatest As New Date pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Value -- _____ DC G
1
4576
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date format? Example, User Defined Date Format as...
2
16765
by: thewilldog | last post by:
Hello, I've reviewed the archives here to address the issue, but I'm still running into problems. I've got a table field populated with the record date in text "YYYYMMDD" To convert it into a...
4
30240
by: Ashraf Ansari | last post by:
Hi, How Can I convert MM/dd/yyyy format into dd/MM/yyyy and the date which is converted into dd/MM/yyyy should be in DateTime format. I do not want to store it as a string. Please help ...
4
2973
by: =?Utf-8?B?YW5kcmV3?= | last post by:
I am running an ASP.net program written in VB. At one point I try to convert a date string into a date time object... this string is from a central dev server and the code works on many other...
4
4505
by: thomasc1020 | last post by:
This is regarding VB.NET 2003. Variable 'Date' is a string and it contains date information in this format: "DEC/05/2007". Now I am trying to convert the format as "2007-12-05". Is it...
0
7105
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
7180
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...
0
7341
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...
0
5439
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,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
266
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...

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.