Solved

Date Format and changing it

Posted on 2013-10-23
4
236 Views
Last Modified: 2013-10-23
If I run A query to find a field that contains a day of the week (%d)
and the return == 01 or 02 how do I change that so it is the date Format for day (%j)
so that there is no leading 0.

for eaxample the code to change it from 01 to 1
02 to 2
03 to 3
however 13 would still be 13 and so forth.
0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 250 total points
ID: 39595748
You could use float e.g.

$p="01";
echo (float)$p;
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 250 total points
ID: 39595782
Personally, I'd use int:

$p="01";
echo (int)$p;

;)
0
 
LVL 7

Author Comment

by:rgranlund
ID: 39595861
What is the difference between float and int?
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39595869
float is for floating point numbers (numbers with a decimal point) and int is for integers - whole numbers only.

Gary was on the right track and deserves the points but as your day is only ever going to be a number between 1 and 31 it makes sense to convert it to an integer!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question