?
Solved

Date Format and changing it

Posted on 2013-10-23
4
Medium Priority
?
240 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 1000 total points
ID: 39595748
You could use float e.g.

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

Accepted Solution

by:
Chris Stanyon earned 1000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

762 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