Store and Retrieve Date in MySQL Database Using Python

Rajendra Dharmkar
Updated on 28-Sep-2023 01:40:28

5K+ Views

To insert a date in a MySQL database, you need to have a column of Type date or datetime in your table. Once you have that, you'll need to convert your date in a string format before inserting it to your database. To do this, you can use the datetime module's strftime formatting function.Example from datetime import datetime now = datetime.now() id = 1 formatted_date = now.strftime('%Y-%m-%d %H:%M:%S') # Assuming you have a cursor named cursor you want to execute this query on: cursor.execute('insert into table(id, date_created) values(%s, %s)', (id, formatted_date))Running this will try to insert the tuple (id, date) ... Read More

Compare Time in Different Time Zones in Python

Vikram Chiluka
Updated on 28-Sep-2023 01:37:36

6K+ Views

In this article, we will show you how to compare time to different timezones in Python using the below methods. Comparing the given Timezone with the local TimeZone Comparing the Current Datetime of Two Timezones Comparing Two Times with different Timezone Method 1: Comparing the given Timezone with the local TimeZone Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task – Use the import keyword, to import the datetime, pytz modules. Use the timezone() function (gets the time zone of a specific location) of the pytz module, to get the timezone ... Read More

How Nested Functions Work in Python

Vikram Chiluka
Updated on 28-Sep-2023 01:30:40

8K+ Views

In this article, we will explain nested/inner functions in Python and how they work with examples. Nested (or inner) functions are functions defined within other functions that allow us to directly access the variables and names defined in the enclosing function. Nested functions can be used to create closures and decorators, among other things. Defining an inner/nested Function Simply use the def keyword to initialize another function within a function to define a nested function. The following program is to demonstrate the inner function in Python − Example # creating an outer function def outerFunc(sample_text): sample_text ... Read More

Centered Pentadecagonal Number

Rinish Patidar
Updated on 27-Sep-2023 16:04:39

234 Views

The problem includes printing the N-th centered pentadecagonal number for any input number N. A centered pentadecagonal number is a number that can be represented in the form of a figure with a dot in the centre and surrounded by successive layers of the pentadecagon i.e. 15-sided polygon. Here the successive layers of the pentadecagon depict that the first layer surrounding the dot in the centre will be 15-sided polygon, the next layer will be 30-sided polygon followed by a 45-sided polygon and so on. We can understand the concept of centered pentadecagonal with the below figures. The first ... Read More

Centered Octagonal Number

Rinish Patidar
Updated on 27-Sep-2023 15:51:40

368 Views

The problem statement includes printing the N-th centered octagonal number for some positive integer N, which will be given by the user. A centered octagonal number is a type of number which can be represented in a pattern of figures. Every centered octagonal number can be represented as a dot in the centre surrounded by the successive layers of an Octagon. An octagon is a type of polygon in geometry which has 8 sides in it. The successive layers of an octagon means that the first layer surrounding the dot in the centre will be an octagon, the second ... Read More

Replace All After Specific Character or Space in Excel

Pradeep Kumar
Updated on 27-Sep-2023 15:49:09

3K+ Views

Excel is a robust spreadsheet programme that provides a wide range of functions to successfully modify and organise data. One frequent task is to change the text in cells based on specific parameters. In order to show you how to carry out these substitutions successfully, we will lead you through step-by-step instructions and examples throughout this lesson. We will also go through how to use these functions with dynamic formulas to handle texts of various lengths. You will have the knowledge and abilities necessary to confidently edit text in Excel at the end of this session, boosting your data processing ... Read More

Replace Accented Characters with Regular Characters in Excel

Pradeep Kumar
Updated on 27-Sep-2023 15:45:31

14K+ Views

Diacritical marks, often known as accented characters, are frequently employed in a variety of languages to denote particular phonetic or linguistic nuances. To make data processing and analysis easier, there are times when you might need to remove certain accents and convert them to their regular counterparts. You will be given step-by-step directions on how to carry out this activity in Microsoft Excel in this tutorial. You will have a strong understanding of how to use built-in Excel functions, formulae, and other practical ways to replace accented characters with regular characters by the end of this session. So let's get ... Read More

Replace Hash Formula Errors in Excel with 0, Blank, or Text

Pradeep Kumar
Updated on 27-Sep-2023 15:44:35

942 Views

You understand how annoying it may be if you've ever run into the dreaded "#" formula errors in your Excel spreadsheets. When there are problems with cell references, mathematical operations, or even data types within your calculations, these errors frequently happen. Fortunately, Excel offers numerous ways to elegantly address these mistakes, improving the presentation of your data and avoiding interruptions to your calculations. Whether you are an experienced Excel user or are just starting started, learning these error-handling strategies can improve your spreadsheet abilities and allow you to produce workbooks that are more robust and presentable. By the time ... Read More

Centered Octadecagonal Number

Rinish Patidar
Updated on 27-Sep-2023 15:43:03

178 Views

The problem includes to print the N-th centered octadecagonal number, where N will be given as an input. A centered octadecagonal number is a type of figurative number which is represented as a dot in the centre surrounded by the successive layers of the octadecagon. An octadecagon is a polygon with 18 sides in it. The successive layers of the octadecagon are the first layer will be 18-sided polygon, the next will be 36-sided polygon and so on. The numbers can be better explained with the help of figures. The first number is represented as a dot in the ... Read More

Repeat Last or Previous Action in Excel

Pradeep Kumar
Updated on 27-Sep-2023 15:37:34

312 Views

Powerful spreadsheet programmes like Excel are frequently used for data analysis, calculations, and information organisation. You might conduct repetitive tasks while using Excel or find that you need to undo and redo some actions. Excel's ability to repeat your most recent action or even go back to one you recently undid is one of its most helpful features. This can help you save time and effort so you can concentrate on other things and organise your workflow. In this tutorial we will look at the easiest way possible to complete the task. So, whether you are an Excel novice or ... Read More

Advertisements